
let selectedOption = null;

const selectButtons = document.querySelectorAll('.select-btn');
const payButton = document.getElementById('pay-btn');

// 选择会员类型
selectButtons.forEach(button => {
    button.addEventListener('click', function () {
        // 移除之前选中的样式
        selectButtons.forEach(btn => btn.classList.remove('selected'));

        // 添加当前选中的样式
        this.classList.add('selected');

        // 设置选中类型
        selectedOption = this.getAttribute('data-type');

        // 激活支付按钮
        payButton.classList.add('active');
        payButton.disabled = false;
    });
});

// 支付按钮点击事件
payButton.addEventListener('click', function () {
    if (!selectedOption) {
        alert('请选择一个会员类型！');
        return;
    }

    // 模拟支付逻辑
    alert(`支付成功！您已开通 ${selectedOption === 'monthly' ? '月度会员' : selectedOption === 'quarterly' ? '季度会员' : '年度会员'}。`);

    // 重置选择
    selectedOption = null;
    selectButtons.forEach(btn => btn.classList.remove('selected'));
    payButton.classList.remove('active');
    payButton.disabled = true;
});
